package com.suyafei.config;

import com.suyafei.interceptor.LoginIntercept;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: suyafei-1024-shop
 * @description
 * @author: luffy
 * @create: 2021-03-01 11:25
 */
@Configuration
@Slf4j
public class InterceptorConfig implements WebMvcConfigurer {

    public LoginIntercept loginIntercept() {
        return new LoginIntercept();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginIntercept())
                .addPathPatterns("/api/user/*/**", "/api/address/*/**")
                .excludePathPatterns("/api/user/*/send_code", "/api/user/*/captcha",
                        "/api/user/*/register", "/api/user/*/login", "/api/user/*/upload");
    }
}
